//获取应用实例
import network from '../../utils/network.js';
const app = getApp()
const baseUrl = 'http://jbc.com';
Page({
    /**
     * 页面的初始数据
     */
    data: {
      isHiddenToast: true,
      page: 1,
      rows: 10,
      total: 0,
      hasMoreData: true,
      list:[],  
      userInfo: [],
      Inx: 0,
    },
 
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function () {
      var that = this;
      wx.getStorage({
        key: 'user',
        success: function (res) {
          that.setData({
            userInfo: res.data,
          });
          that.onGetFlowProductList("加载数据列表");
        }
      });
    },

  onGetFlowProductList: function (message) {
    var that = this;
    var userInfo = that.data.userInfo;
    var latituded; var longituded; 
      var data = {
        member_id: that.data.userInfo.id,
      };
    network.requestLoading(baseUrl +'/api/Member/getBrowsing', data, message, function (res) {
        var contentlistTem = that.data.list;
        if (res.code > 0) {
          if (contentlistTem.length < res.data.total) {
            that.setData({
              page: that.data.page + 1,
              list: res.data.list,
            });

            console.log(that.data.list);
          } else {
            that.setData({
              hasMoreData: false
            });
          }
        } else {
          // wx.showToast({
          //   title: res.msg,
          // });
        }
      }, function (res) {
        wx.showToast({
          title: '加载数据失败',
        })

      })  

  },
  /*
  *进入门店
  */
  onGoShop: function (e) {
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/view/join_team/join_team?id=' + id,
    });
  },
  /**
* 页面相关事件处理函数--监听用户下拉动作
*/
  onPullDownRefresh: function () {
    this.data.page = 1;
    this.onGetShopList('正在刷新数据')
    console.log("下拉加载更多")
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    console.log("下滑加载更多")
    if (this.data.hasMoreData) {
      this.onGetShopList('加载更多数据');
    } else {
      console.log("没有更多的数据")
      wx.showToast({
        title: '没有更多数据',
      })
    }
  },
 
})

